Optimal. Leaf size=67 \[ \frac {B x}{b}+\frac {2 (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} b \sqrt {a+b} d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.05, antiderivative size = 67, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 3, integrand size = 23, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {2814, 2738,
211} \begin {gather*} \frac {2 (A b-a B) \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{b d \sqrt {a-b} \sqrt {a+b}}+\frac {B x}{b} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rule 2814
Rubi steps
\begin {align*} \int \frac {A+B \cos (c+d x)}{a+b \cos (c+d x)} \, dx &=\frac {B x}{b}-\frac {(-A b+a B) \int \frac {1}{a+b \cos (c+d x)} \, dx}{b}\\ &=\frac {B x}{b}+\frac {(2 (A b-a B)) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{b d}\\ &=\frac {B x}{b}+\frac {2 (A b-a B) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{\sqrt {a-b} b \sqrt {a+b} d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.14, size = 68, normalized size = 1.01 \begin {gather*} \frac {B (c+d x)+\frac {2 (-A b+a B) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {-a^2+b^2}}\right )}{\sqrt {-a^2+b^2}}}{b d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.16, size = 73, normalized size = 1.09
method | result | size |
derivativedivides | \(\frac {\frac {2 \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {2 B \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b}}{d}\) | \(73\) |
default | \(\frac {\frac {2 \left (A b -a B \right ) \arctan \left (\frac {\tan \left (\frac {d x}{2}+\frac {c}{2}\right ) \left (a -b \right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{b \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {2 B \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{b}}{d}\) | \(73\) |
risch | \(\frac {B x}{b}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{2}-i b^{2}+a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) a B}{\sqrt {-a^{2}+b^{2}}\, d b}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) A}{\sqrt {-a^{2}+b^{2}}\, d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{2}-i b^{2}-a \sqrt {-a^{2}+b^{2}}}{b \sqrt {-a^{2}+b^{2}}}\right ) a B}{\sqrt {-a^{2}+b^{2}}\, d b}\) | \(294\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.38, size = 242, normalized size = 3.61 \begin {gather*} \left [\frac {2 \, {\left (B a^{2} - B b^{2}\right )} d x + {\left (B a - A b\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {2 \, a b \cos \left (d x + c\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (d x + c\right ) + b\right )} \sin \left (d x + c\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + a^{2}}\right )}{2 \, {\left (a^{2} b - b^{3}\right )} d}, \frac {{\left (B a^{2} - B b^{2}\right )} d x - {\left (B a - A b\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (d x + c\right )}\right )}{{\left (a^{2} b - b^{3}\right )} d}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 524 vs.
\(2 (56) = 112\).
time = 12.77, size = 524, normalized size = 7.82 \begin {gather*} \begin {cases} \frac {\tilde {\infty } x \left (A + B \cos {\left (c \right )}\right )}{\cos {\left (c \right )}} & \text {for}\: a = 0 \wedge b = 0 \wedge d = 0 \\\frac {A \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{b d} + \frac {B x}{b} - \frac {B \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{b d} & \text {for}\: a = b \\\frac {A}{b d \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}} + \frac {B x}{b} + \frac {B}{b d \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}} & \text {for}\: a = - b \\\frac {A x + \frac {B \sin {\left (c + d x \right )}}{d}}{a} & \text {for}\: b = 0 \\\frac {x \left (A + B \cos {\left (c \right )}\right )}{a + b \cos {\left (c \right )}} & \text {for}\: d = 0 \\\frac {A b \log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {A b \log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} + \frac {B a d x \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {B a \log {\left (- \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} + \frac {B a \log {\left (\sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} + \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )} \right )}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} - \frac {B b d x \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}}{a b d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}} - b^{2} d \sqrt {- \frac {a}{a - b} - \frac {b}{a - b}}} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 296 vs.
\(2 (58) = 116\).
time = 0.47, size = 296, normalized size = 4.42 \begin {gather*} -\frac {\frac {{\left (\sqrt {a^{2} - b^{2}} B {\left (2 \, a - b\right )} {\left | a - b \right |} - \sqrt {a^{2} - b^{2}} A b {\left | a - b \right |} - \sqrt {a^{2} - b^{2}} A {\left | a - b \right |} {\left | b \right |} + \sqrt {a^{2} - b^{2}} B {\left | a - b \right |} {\left | b \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a + \sqrt {-4 \, {\left (a + b\right )} {\left (a - b\right )} + 4 \, a^{2}}}{a - b}}}\right )\right )}}{{\left (a^{2} - 2 \, a b + b^{2}\right )} b^{2} + {\left (a^{3} - 2 \, a^{2} b + a b^{2}\right )} {\left | b \right |}} + \frac {{\left (2 \, B a - A b - B b + A {\left | b \right |} - B {\left | b \right |}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor + \arctan \left (\frac {2 \, \sqrt {\frac {1}{2}} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {\frac {2 \, a - \sqrt {-4 \, {\left (a + b\right )} {\left (a - b\right )} + 4 \, a^{2}}}{a - b}}}\right )\right )}}{b^{2} - a {\left | b \right |}}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 1.72, size = 344, normalized size = 5.13 \begin {gather*} \frac {a\,\left (B\,\ln \left (\frac {b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {-\left (a+b\right )\,\left (a-b\right )}-B\,\ln \left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {b^2-a^2}\right )-A\,b\,\ln \left (\frac {b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {-\left (a+b\right )\,\left (a-b\right )}+A\,b\,\ln \left (\frac {a\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )-b\,\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )+\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {b^2-a^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\sqrt {b^2-a^2}}{b\,d\,\left (a^2-b^2\right )}+\frac {2\,B\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{b\,d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________